During execution, the executable code of an application requests the use of the memory available in the data processing system. Memory is allocated to an application for instantiating data structures, such as objects of a class, storage for variable data, temporary storage of data during computations, and for many other purposes.
The memory management subsystem of the data processing system expects that application to release any unused memory that was allocated to the application. Ideally, the application should promptly request memory as needed, release any unused memory during the operations, and no memory should remain allocated to the application when the application terminates.
Many applications allocate too much memory before releasing any unused memory, or fail to release unused memory. Over-allocation of memory to an application can cause memory shortage for other applications. Failure to release unused memory has similar results. In some cases, the memory management subsystem exhausts a threshold amount of allocable memory resulting in delays, disruptions, or even failures in other applications executing on the data processing system.
An actual memory leak is the phenomenon in a data processing system where the available pool of allocable memory is depleted by allocating more and more memory to an application without receiving back unused memory from the application. Over-allocation of memory, to wit, allocation of memory above a threshold amount of memory to an application, can also look like a memory leak even though the application may be using all of the allocated memory. An actual memory leak or a leak-like over-allocation is collectively referred to hereinafter as “leak” or “memory leak”.